package com.zk;

import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;

public class HttpClientExample {

	// =============
	// 构建 URI
	// =============

	private final static Logger logger = LoggerFactory.getLogger(HttpClientExample.class);

	private String buildNewDownListURL(Map<String, Object> baseInfo) {
		URI uri = null;
		try {
			uri = new URIBuilder("http://v2.tongbu.com/app/api/newdownlist")
			.addParameter("sku", String.valueOf(baseInfo.getOrDefault("sku", "")))
			.addParameter("appleid", String.valueOf(baseInfo.getOrDefault("appleid", -1)))
			.build();
		} catch (URISyntaxException e) {
			logger.error("Error Build URI. Cause: " + e.toString());
		}

		if (uri != null) {
			return uri.getPath();
		}

		return null;
	}
}